export const styleData = [
  { key: "left", label: "x 坐标" },
  { key: "top", label: "y 坐标" },
  // { key: "rotate", label: "旋转角度" },
  { key: "width", label: "宽" },
  { key: "height", label: "高" },
  { key: "color", label: "颜色" },
  { key: "backgroundColor", label: "背景色" },
  { key: "display", label: "显示隐藏display" },
  { key: "visibility", label: "显示隐藏visibility" },

  // { key: "borderWidth", label: "边框宽度" },
  // { key: "borderStyle", label: "边框风格" },
  // { key: "borderColor", label: "边框颜色" },
  // { key: "borderRadius", label: "边框半径" },
  { key: "fontSize", label: "字体大小" },
  { key: "fontWeight", label: "字体粗细" },
  { key: "lineHeight", label: "行高" },
  { key: "letterSpacing", label: "字间距" },
  { key: "textAlign", label: "左右对齐" },
  { key: "verticalAlign", label: "上下对齐" }
  // { key: "opacity", label: "不透明度" },
];
export const selectKey = ["textAlign", "borderStyle", "verticalAlign", "visibility", "display"];
export const textAlignOptions = [
  {
    label: "左对齐",
    value: "left"
  },
  {
    label: "居中",
    value: "center"
  },
  {
    label: "右对齐",
    value: "right"
  }
];

export const borderStyleOptions = [
  {
    label: "实线",
    value: "solid"
  },
  {
    label: "虚线",
    value: "dashed"
  }
];

export const verticalAlignOptions = [
  {
    label: "上对齐",
    value: "top"
  },
  {
    label: "居中对齐",
    value: "middle"
  },
  {
    label: "下对齐",
    value: "bottom"
  }
];
export const visibilityOptions = [
  {
    label: "显示",
    value: "visible"
  },
  {
    label: "隐藏",
    value: "hidden"
  }
];
export const displayOptions = [
  {
    label: "显示",
    value: "block"
  },
  {
    label: "隐藏",
    value: "none"
  }
];
export const optionMap = {
  textAlign: textAlignOptions,
  borderStyle: borderStyleOptions,
  verticalAlign: verticalAlignOptions,
  visibility: visibilityOptions,
  display: displayOptions
};
export function parseObjectLiteral(str) {
  try {
    // Remove leading and trailing whitespace
    str = str.trim();
    // Check the first character of the string
    if (str.startsWith("{")) {
      // Make sure the string is wrapped in braces
      if (!str.endsWith("}")) {
        str = str + "}";
      }
      // Create a new function that returns the object
      const func = new Function("return " + str);
      // Call the function to get the object
      return func();
    } else if (str.startsWith("[")) {
      // Make sure the string is wrapped in braces
      if (!str.endsWith("]")) {
        str = str + "]";
      }
      // Create a new function that returns the object
      const func = new Function("return " + str);
      // Call the function to get the object
      return func();
    } else {
      // The string is not a valid object or array
      console.log("Invalid input string");
      return null;
    }
  } catch (e) {
    console.log(e);
    return null;
  }
}
